package severlet;

import bean.Express;
import dao.ExpressDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

//
@WebServlet(name = "StudentExpressServlet", value = "/StudentExpressServlet")
public class StudentExpressServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        //学生登录之后获取他的名字
        String studentname = (String) request.getSession().getAttribute("studentname");
        //数据库的查询
        ExpressDao expressDao=new ExpressDao();
        ArrayList<Express> studentExperssList = expressDao.getExpressInfoByStudentname(studentname);
        //存入session用于前端调用
        request.getSession().setAttribute("studentExpress",studentExperssList);
        request.getRequestDispatcher("student_express.jsp").forward(request,response);


    }
}
